//
//  DBYDestinationCell.m
//  MemoryTravel
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "DBYDestinationCell.h"

@implementation DBYDestinationCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews
{
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10 , 5  , 120, 90 )];
    self.imageV.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.imageV];
    
    self.imageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageV.frame.size.height - 20 , self.imageV.frame.size.width, 20 )];
    [self.imageV addSubview:self.imageLabel];
    self.imageLabel.backgroundColor = [UIColor colorWithWhite:0.247 alpha:0.5];
    
    self.titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(self.imageV.frame.origin.x + self.imageV.frame.size.width + 10 , self.imageV.frame.origin.y + 5 , Width - 160 , 10 )];
    [self.contentView addSubview:self.titleLabel];
    
    self.dLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height + 15 , self.titleLabel.frame.size.width, 30 )];
    
    [self.contentView addSubview:self.dLabel];
}

-(void)setAModel:(DBYDestinationModel *)aModel{
    
    if (_aModel != aModel) {
        _aModel = aModel;
    }
    
    
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:self.aModel.image_url] placeholderImage:[UIImage imageNamed:@"loading.jpg"]];
    
    self.imageLabel.text = [NSString stringWithFormat:@"%@ 人去过",self.aModel.attraction_trips_count];
    self.imageLabel.font = [UIFont systemFontOfSize:12];
    self.imageLabel.textAlignment = NSTextAlignmentCenter;
    self.imageLabel.textColor = [UIColor whiteColor];
    
    self.titleLabel.text = self.aModel.name;
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    
    self.dLabel.text = self.aModel.placeDescription;
    self.dLabel.font = [UIFont systemFontOfSize:12];
    self.dLabel.numberOfLines = 0;

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
